<%@ page import="ar.com.photo_admin.domain.PurchaseOrder" %>
<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
	<meta name="layout" content="main">
	<r:require module="export"/>
</head>
<body>
	<div class="page-header">
		<h1>
			<g:message code="purchase.title2" />
		</h1>
	</div>
		
	<g:if test="${flash.message}">
		<div class="alert alert-success">  
		  <a class="close" data-dismiss="alert">×</a>  
		  <div class="message">${flash.message}</div>  
		</div>  
	</g:if>
	
		
	<g:if test="${purchaseOrderInstanceList.size()>0}">
		<export:formats id="exportFormats" formats="['csv', 'excel', 'ods', 'pdf']" />
		<div class="separator"></div>
					
		<div class="row">
			<table class="table table-striped span12">
				<thead>
					<tr>					
						<g:sortableColumn property="id" title="${message(code: 'purchase.number')}" />
						<g:sortableColumn property="status" title="${message(code: 'purchase.status')}" />
						<g:sortableColumn property="dateCreated" title="${message(code: 'purchase.date')}" />											
						<g:sortableColumn property="price" title="${message(code: 'purchase.price')}" />
						<g:sortableColumn property="amountCopies" title="${message(code: 'purchase.photos.size')}" />
						<g:sortableColumn property="client.username" title="${message(code: 'purchase.client')}" />
						<g:sortableColumn property="photographer.username" title="${message(code: 'purchase.photographer')}" />
						<th> </th>
					</tr>
				</thead>
				<tbody>
					<g:each in="${purchaseOrderInstanceList}" status="i" var="purchaseOrderInstance">
						<tr>
							<td><g:link action="show" id="${purchaseOrderInstance.id}">${purchaseOrderInstance.id}</g:link></td>
							<td> ${purchaseOrderInstance.state.showDescription()}</td>
							<td><g:formatDate format="dd-MM-yyyy"  date="${purchaseOrderInstance.dateCreated}" /></td>
							<td>${fieldValue(bean: purchaseOrderInstance, field: "price")}</td>
							<td>${fieldValue(bean: purchaseOrderInstance, field: "amountCopies")}</td>
							<td>${fieldValue(bean: purchaseOrderInstance, field: "client.username")}</td>
							<td>${fieldValue(bean: purchaseOrderInstance, field: "photographer.username")}</td>
							<td>
								<div class="menuButton">
									<g:link class="pdf" action="show" id="${purchaseOrderInstance.id}" params="['format':'pdf','extension':'pdf']"></g:link>
									<g:link class="excel" action="show" id="${purchaseOrderInstance.id}" params="['format':'excel','extension':'xls']"></g:link>
								</div>
							</td>
						</tr>
					</g:each>
				</tbody>
			</table>
			
		</div>
		<div class="paginateButtons row centered"  >
				<g:paginate total="${total}"/>
		</div>				
	</g:if>
	<g:else>
		<div id="noPhotosInCart" class="alert alert-warning">  
		  <a class="close" data-dismiss="alert">×</a>  
		  <div class="message"><g:message code="purchase.noElements" /></div>  
		</div>
	</g:else>
	
	<script type="text/javascript">
       
	jQuery(document).ready(function(){	
		
		$('.export').removeClass("export").addClass("btn-group");
		$('#exportFormats > .menuButton').addClass("btn");
		$('#exportFormats > .menuButton > a').css("text-decoration", "none");

   	});
    </script>	
    
	</body>
</html>
